<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<c:set var="ctx" value="${pageContext.request.contextPath}" />

  <table lay-filter="layerTable" lay-skin="line">
    <thead>
      <tr>
        <th class="xutd" lay-data="{field:'xutdId', width:60,fixed:'left'}">序号</th>
		<th lay-data="{field:'authame'}">资源名称</th>
		<th lay-data="{field:'shiroCode'}">shiro标识</th>
		<th lay-data="{field:'authResourceUrl'}">资源地址</th>
		<th lay-data="{field:'authResourceType'}">资源类型</th>
		<th lay-data="{field:'sortNo',sort:true}">排序</th>
		<th lay-data="{field:'createTime',fixed:'right'}">创建时间</th>
	    <th lay-data="{field:'setting', width:130,fixed:'right'}">操作</th>
      </tr>
    </thead>
    <tbody>
      <c:forEach items="${pager.result}" var="item" varStatus="index">
	      <tr>
	        <td>${(index.index+1)+pager.pageParameter.pageSize*(pager.pageParameter.current-1) }</td>
			<td>${item.authName}</td>
			<td>${item.authShrioCode}</td>
			<td>${item.authUrl}</td>
			<td>
				<c:if test="${item.authType == 'MODULAR'}">模块</c:if>
				<c:if test="${item.authType == 'MENU'}">菜单</c:if>
				<c:if test="${item.authType == 'FUNCTIONS'}">功能</c:if>
			</td>
			<td>${item.authNo}</td>
			<td>${item.createTime}</td>
		    <td>
				<shiro:hasPermission name="sysman:SYSTEM_AUTH_MAN:edit">
					<button class="layui-btn layui-btn-small editBtn" type="button" data-id="${item.authCode}" onclick="toEdit(this);">
						<i class="layui-icon" title="编辑">&#xe642;</i>
					</button>
				</shiro:hasPermission>
				<shiro:hasPermission name="sysman:SYSTEM_AUTH_MAN:delete">
					<button class="layui-btn layui-btn-small layui-btn-danger delBtn" type="button" data-id="${item.authCode}" onclick="toDel(this);">
						<i class="layui-icon" title="删除">&#xe640;</i>
					</button>
				</shiro:hasPermission>
			</td>
	      </tr>
      </c:forEach>
    </tbody>
  </table>
<div id="layer-page"></div>
<input type="hidden" id="currentPage" value="${pager.pageParameter.current}" />
<input type="hidden" id="pageSize" value="${pager.pageParameter.pageSize}" />
<script type="text/javascript">
    layui.use(['table', 'laypage'], function(){
        var table = layui.table;
        //转换静态表格
        table.init('layerTable', {
            height: $(window).height() - 210, //设置高度,
            limit:${pager.pageParameter.pageSize}
        });
        var laypage = layui.laypage;
        //执行一个laypage实例
        laypage.render({
            elem: 'layer-page' //注意，这里的 test1 是 ID，不用加 # 号
            ,limits:[20,40,60,80,100,200]
            ,limit:${pager.pageParameter.pageSize}
            ,curr:${pager.pageParameter.current}
            ,count: ${pager.pageParameter.totalCount} //数据总数，从服务端得到
            ,layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
            ,jump: function(obj, first){
                console.log(obj.curr);
                console.log(obj.limit);
                //首次不执行
                if(!first){
                    baseSearchQueryLayer(obj.curr,obj.limit);
                    //转换静态表格
                }
            }
        });

        window.onresize = function() {
            $(".zTreeDemoBackground").height($(window).height()-210);
            $("#pageList").width($(window).width()-300);
            $(".rightinfo").height($(window).height()-80);
            //转换静态表格
            table.init('layerTable', {
                height: $(window).height() - 210, //设置高度,
                limit:${pager.pageParameter.pageSize}
            });
        }
    });
    function toDel(obj){
        baseSelDel(obj);
    }

    function toEdit(obj){
        toBaseSelEdit(obj,false,933,530,true);
    }
</script>